<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script type="text/javascript" src="/static/plugs/jquery-3.4.1/jquery-3.4.1.min.js"></script>
    <script type="text/javascript" src="/static/plugs/jq/jquery.qrcode.min.js"></script>
</head>
<style>
    div{
        position: absolute;      /*这里可以改成fixed*/
        top: 50%;
        left: 50%;
        margin-top: -150px;
        margin-left: -150px;
    }
</style>
<body>

    <div id="code"></div>        
    <script>
        $("#code").qrcode({
            render: "table", //table方式
            width: 250, //宽度
            height: 250, //高度
            text: "http://www.ydcrms.com:8013/wx/app/callback?aid="+{$aid}//任意内容
        });
        ws = new WebSocket("ws://127.0.0.1:2346");
        ws.onopen = function() {
            console.log("连接成功");
            //ws.send('tom');
        };
        ws.onmessage = function(e) {
            if(e.data == 'ok'){
                $('#code').hide(5000);   
            }
            console.log("收到服务端的消息： " + e.data);
            //ws.send('保持连接， 发第二次信息， 查看服务器回应');
        };   
    </script>
</body>

</html>